#!usr/bin/perl -w

#定义了WizardPage类
package WizardPage;

require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(Parse);
use strict;

require ValueQuery;
require TextQuery;
require CapabilityQuery;
require UidQuery;

sub new()
{
	my $self={};
	bless $self;
	$self->Construct();
	return $self;
}

sub Construct()
{
	my $this=shift;
	$this->{'iTxtQuery'}=[];
	$this->{'iValueQuery'}=[];
	$this->{'iUidQuery'}=[];
	$this->{'iCapbilityQuery'}=[];
}

sub Parse()
{
	my $this=shift;
	my ($ref)=@_;

	foreach (my($key,$value)=each %$ref)
	{
		my $newQuery=undef;

		if ($key eq "textquery")
		{
			$newQuery=new TextQuery();
			$this->Add($newQuery,"iTxtQuery");
		}
		elsif ($key eq "uidquery")
		{
			$newQuery=new UidQuery();
			$this->Add($newQuery,"iUidQuery");
		}
		elsif ($key eq "capabilityquery")
		{
			$newQuery=new CapabilityQuery;
			$this->Add($newQuery,"iCapbilityQuery");
		}
		elsif ($key eq "valuequery")
		{
			$newQuery=new ValueQuery();
			$this->Add($newQuery,"iValueQuery");
		}

		#解析
		if (defined $newQuery)
		{
			$newQuery->Parse($value);
		}
	}
}

sub TxtQueryArray()
{
	my $this=shift;
	return $this->{'iTxtQuery'};
}

sub ValueQueryArray()
{
	my $this=shift;
	return $this->{'iValueQuery'};
}
sub UidQueryArray()
{
	my $this=shift;
	return $this->{'iUidQuery'};
}
sub CapQueryArray()
{
	my $this=shift;
	return $this->{'iCapbilityQuery'};
}

sub Add()
{
	my $this=shift;
	my ($item,$member)=@_;
	my @array=$this->{$member};
	push @array,$item;
}

1;

